#include <iostream>
using namespace std;
class CNY;
class USD{
public:
USD(double value)
:_value(value)
{
    cout<<"USD(double)"<<endl;
}
friend ostream & operator<<(ostream &os,const USD&rhs);
friend class CNY;
private:
double _value;
};
class CNY{
public:
    CNY(double value)
    :_value(value)
    {
        cout<<"CNY(double)"<<endl;
    }

    CNY & operator=(const USD& rhs){
        cout<<"operator=(const USD& )"<<endl;
        _value=rhs._value*7.14;
        return *this;
    }
    CNY(const USD &rhs)
    :_value(rhs._value*7.14)
    {
        cout<<"CNY(const USD&)"<<endl;

    }
    friend ostream &operator<<(ostream &os,const CNY & rhs);
private:
double _value;

};
ostream & operator<<(ostream& os,const USD & rhs){
    os<<rhs._value<<"$";
    return os;
}
ostream & operator<<(ostream &os,const CNY & rhs){
    os<<rhs._value<<"￥";
    return os;
}


void test(){
    USD usd(100);
    cout<<usd<<endl;
    CNY cny(100);
    cout<<cny<<endl;

    cny=usd;
    cout<<cny<<endl;
}
void test2(){
    USD usd(100);
    CNY cny=usd;
    cout<<cny<<endl;
}
int main(int argc, char * argv[]){
    test();
    test2();
    return 0;
}

